package com.clever.springssm.controller;

import com.clever.springssm.entity.Product;
import com.clever.springssm.service.ProductService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author ChenWang
 * @className ProductController
 * @date 2020/10/30 10:49
 * @since JDK 1.8
 */
@RestController
@RequestMapping("/product")
public class ProductController {
    @Resource
    private ProductService productService;
    @GetMapping("/list")
    public List<Product> list(){
        List<Product> products = null;
        try{
            products = productService.findAll();
        }catch (Exception e){
            e.printStackTrace();
        }
        return products;
    }
    @GetMapping("/test")
    public String test(){
        return "这是一个测试";
    }

}
